<?php

namespace App\Http\Requests;

use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;

class MenuRequest extends AdminRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'pid' => 'required',
            'title' => 'required',
            'is_menu' => 'digits:1',
        ];
    }

    /**
     * 重写错误信息
     *
     * @return array
     */
    public function messages()
    {
        $message = [
            'pid.required' => '父id必须填写',
            'title.required' => '名称必须填写',
            'is_menu.required' => '侧边菜单不能为空',
        ];
        return $message;
    }
}
